﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using IHISCETeim.BLL;
using IHISCETeim.Library;
using IHISCETeim.Model;

namespace IHISCETeim.Web.MachineSys.UserModel
{
    public partial class UMacKeepDetailAdd : PageBase
    {
        protected override Permission[] PowerKey
        {
            get
            {
                return new Permission[] { Permission.新增 };
            }
        }
        protected override string DWZRef
        {
            get { return "UMacKeepList"; }
        }


        protected void Page_Load(object sender, EventArgs e)
        {
            if (GetRequestValue<string>("ajaxmethod", "") == "add")
            {
                addmenu();
            }
        }
        private void addmenu()
        {
           

            //if (UMacKeepController.Add(obj) > 0)
            //    SuccessJson("添加成功", this.DWZRef);
            //else
            //    ErrorJson("添加失败", this.DWZRef);
            
                string[] SerialNumbers = GetRequestValue<string>("SerialNumber", "").Split(new char[] { ',' });
                string[] KeepHourss = GetRequestValue<string>("KeepHours", "").Split(new char[] { ',' });
                string[] WorkTimes = GetRequestValue<string>("WorkTime", "").Split(new char[] { ',' });
                string[] KeepDates = GetRequestValue<string>("KeepDate", "").Split(new char[] { ',' });

                for (int index = 0; index < SerialNumbers.Count(); index++)
                {
                    if (string.IsNullOrEmpty(SerialNumbers[index]))
                    {
                        continue;
                    }
                    UMacKeepDetailInfo item = new UMacKeepDetailInfo();
                    item.SerialNumber = SerialNumbers[index];
                    item.KeepHours = Convert.ToInt32(KeepHourss[index]);
                    item.WorkTime = Convert.ToDecimal(WorkTimes[index]);
                    item.KeepDate = KeepDates[index];
                    UMacKeepController.UMacKeepDetail_Add(item);
                    AddLog(Permission.新增, item);
                }

                SuccessJson("添加成功", this.DWZRef);
            
        }
        private string KeepHourshtml = "";
        protected string GetKeepHourssHtml()
        {
            if (!string.IsNullOrEmpty(KeepHourshtml))
                return KeepHourshtml;
            string[] xx = new string[] { "50","250","500","750","1000","1250","1500","1750","2000"};
            string HTML = "<select name='KeepHours' class='combox'>";
            foreach (string ix in xx)
            {
                HTML +=string.Format("<option value='{0}'>{1}</option>",ix,ix+"小时保养");
            }
            HTML += "</select>";
            KeepHourshtml = HTML;
            return KeepHourshtml;
        }
    }
}